<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增客户信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-add">
<!--            <div class="form-group">
                <label class="col-sm-3 control-label is-required">客户编号：</label>
                <div class="col-sm-8">
                    <input name="cstno" class="form-control" type="text" required>
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户公司名称：</label>
                <div class="col-sm-8">
                    <input name="userName" id="userName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户电话：</label>
                <div class="col-sm-8">
                    <input id="cusPhone" name="cusPhone" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户邮箱：</label>
                <div class="col-sm-8">
                    <input id="cusEmail" name="cusEmail" class="form-control" type="text" maxlength="50" placeholder="请输入邮箱" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户联系人：</label>
                <div class="col-sm-8">
                    <input name="cusConcatName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">送货地址：</label>
                <div class="col-sm-8">
                    <input name="shippingAddress" class="form-control" type="text" required>
                </div>
            </div>
<!--            <div class="form-group">
                <div class="cusType" style="margin-left: -95px">
                    <label class="col-sm-4 control-label">客户类型：</label>
                    <div class="col-sm-8">
                        <select name="cusType" class="form-control m-b" th:with="type=${@dict.getType('customer_type')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/info"
        $("#form-info-add").validate({
            onkeyup: false,
            rules:{
                cusEmail:{
                    email:true,
                    remote: {
                        url: prefix + "/checkEmailUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "email": function () {
                                return $.common.trim($("#email").val());
                            }
                        },
                        dataFilter: function (data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
                userName:{
                    remote: {
                        url: prefix + "/checkUserName",
                        type: "post",
                        dataType: "json",
                        data: {
                            "userName": function () {
                                return $.common.trim($("#userName").val());
                            }
                        },
                        dataFilter: function (data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
                cusPhone:{
                    isPhone:true,
                    remote: {
                        url: prefix + "/checkPhoneUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "cusPhone": function () {
                                return $.common.trim($("#cusPhone").val());
                            }
                        },
                        dataFilter: function (data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
            },
            messages: {
                "cusEmail": {
                    remote: "Email已经存在"
                },
                "cusPhone": {
                    remote: "手机号码已经存在"
                },
                "userName": {
                    remote: "公司名称不能重复"
                }
            },
        })
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-info-add').serialize());
            }
        }
    </script>
</body>
</html>